<template>
  <div class="wrap header">
    <h1>
      <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
    </h1>
    <ul class="navs">
      <!-- {{$route.path}} -->
      <li
        @click="$router.push('/home')"
        :class="{ cur: $route.path == '/home' }"
      >
        首页
      </li>
      <li
        @click="$router.push('/goods')"
        :class="{ cur: $route.path == '/goods' }"
      >
        全部商品
      </li>
      <li
        @click="$router.push('/user')"
        :class="{ cur: $route.path == '/user' }"
      >
        个人中心
      </li>
      <li
        @click="$router.push('/order')"
        :class="{ cur: $route.path == '/order' }"
      >
        我的订单
      </li>
      <li
        @click="$router.push('/free')"
        :class="{ cur: $route.path == '/free' }"
      >
        专属福利
      </li>
      <li
        @click="$router.push('/expand')"
        :class="{ cur: $route.path == '/expand' }"
      >
        vue拓展
      </li>
    </ul>
    <div class="search">
      <input type="text" placeholder="输入关键字" v-model="searchVal" />
      <span class="searchBtn" @click="searchFn">
        <img src="../assets/img/search.png" alt="" />
      </span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchVal: "",
    };
  },
  methods: {
    searchFn() {
      this.$router.push(`/goods?keyword=${this.searchVal}`);
      this.searchVal = "";
    },
  },
};
</script>

<style lang="less" scoped>
.header {
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 10px auto;
  img {
    vertical-align: middle;
  }

  .navs {
    display: flex;
    justify-content: space-between;
    width: 500px;
    height: 16px;
    font-size: 16px;
    font-weight: 500;
    line-height: 23px;
    cursor: pointer;
  }
  .search {
    display: flex;
    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      box-sizing: border-box;
      text-indent: 1em;
      outline: none;
    }
    .searchBtn {
      width: 50px;
      height: 40px;
      line-height: 40px;
      text-align: center;
      display: inline-block;
      background: #0a328e;
      cursor: pointer;
      border-radius: 0px 20px 20px 0px;
    }
  }
  .cur {
    color: #0a328e;
    font-weight: 700;
  }
}
</style>